package com.ccb.lms.service;

import java.sql.SQLException;
import java.util.List;

import com.ccb.lms.facade.FacadeDAO;
import com.ccb.lms.model.Library;
import com.ccb.lms.util.BasePage;


public class LibraryService implements ILibraryService {
	
	private FacadeDAO facadeDAO=null;


	public FacadeDAO getFacadeDAO() {
		return facadeDAO;
	}

	public void setFacadeDAO(FacadeDAO facadeDAO) {
		this.facadeDAO = facadeDAO;
	}

	public boolean deleteLibrary(Integer libraryNO) {
		try {
			return facadeDAO.getLibraryDAO().deleteLibrary(libraryNO);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}

	public List<Library> getAllLibrary() {
		try {
			return facadeDAO.getLibraryDAO().getAllLibrary();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	public Library getLibraryById(Integer libraryNO) {
		try {
			return facadeDAO.getLibraryDAO().getLibraryById(libraryNO);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	public boolean insertLibrary(Library library) {
		try {
			return facadeDAO.getLibraryDAO().insertLibrary(library);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}


	public boolean updateLibrary(Library library) {
		try {
			return facadeDAO.getLibraryDAO().updateLibrary(library);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}

	public List<Library> getLibraryByPage(BasePage basePage) {
		try {
			return facadeDAO.getLibraryDAO().getLibraryByPage(basePage);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	public int getLibraryCount() {
		try {
			return facadeDAO.getLibraryDAO().getLibraryCount();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return 0;
	}

	public BasePage getBasePage(int currentPage, int showRecordNum) {
		try {
			return facadeDAO.getLibraryDAO().getBasePage(currentPage, showRecordNum);
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return null;
	}

}

